home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Info / TeachU14 / SAMS / Code / Day13 / webbrwsu.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-08  |  3.0 KB  |  89 lines

  1. //---------------------------------------------------------------------------
  2. #include <vcl\vcl.h>
  3. #pragma hdrstop
  4.  
  5. #include "WebBrwsU.h"
  6. //---------------------------------------------------------------------------
  7. #pragma package(smart_init)
  8. #pragma resource "*.dfm"
  9. TWebMain *WebMain;
  10. //---------------------------------------------------------------------------
  11. __fastcall TWebMain::TWebMain(TComponent* Owner)
  12.     : TForm(Owner)
  13. {
  14. }
  15. //---------------------------------------------------------------------------
  16. void __fastcall TWebMain::URLComboBoxClick(TObject *Sender)
  17. {
  18.   if (URLComboBox->Text != "")
  19.     HTML->RequestDoc(URLComboBox->Text);
  20. }
  21. //---------------------------------------------------------------------------
  22. void __fastcall TWebMain::URLComboBoxKeyPress(TObject *Sender, char &Key)
  23. {
  24.   if (Key == VK_RETURN) {
  25.     Key = 0;
  26.     if (URLComboBox->Text == "") return;
  27.     URLComboBoxClick(Sender);
  28.   }
  29. }
  30. //---------------------------------------------------------------------------
  31. void __fastcall TWebMain::HTMLUpdateRetrieval(TObject *Sender)
  32. {
  33.   int total = HTML->RetrieveBytesTotal;
  34.   int done = HTML->RetrieveBytesDone;
  35.   int percent;
  36.   if (total == 0 || done == 0)
  37.     percent = 0;
  38.   else
  39.     percent = ((done * 100) / total);
  40.   char buff[80];
  41.   wsprintf(buff,
  42.     "Getting Document: %d%% of %dK", percent, total/1024);
  43.   StatusBar->SimpleText = buff;
  44. }
  45. //---------------------------------------------------------------------------
  46. void __fastcall TWebMain::HTMLEndRetrieval(TObject *Sender)
  47. {
  48.   StatusBar->SimpleText = "Done";
  49. }
  50. //---------------------------------------------------------------------------
  51. void __fastcall TWebMain::GoBtnClick(TObject *Sender)
  52. {
  53.   URLComboBoxClick(0);    
  54. }
  55. //---------------------------------------------------------------------------
  56. void __fastcall TWebMain::StopBtnClick(TObject *Sender)
  57. {
  58.   HTML->Cancel(0);
  59.   StatusBar->SimpleText = "Done";
  60. }
  61. //---------------------------------------------------------------------------
  62. void __fastcall TWebMain::ReloadBtnClick(TObject *Sender)
  63. {
  64.   URLComboBoxClick(0);
  65. }
  66. //---------------------------------------------------------------------------
  67. void __fastcall TWebMain::SourceBtnClick(TObject *Sender)
  68. {
  69.   HTML->ViewSource = !HTML->ViewSource;
  70.   if (HTML->ViewSource)
  71.     SourceBtn->Caption = "View Document";
  72.   else
  73.     SourceBtn->Caption = "View Source";
  74. }
  75. //---------------------------------------------------------------------------
  76. void __fastcall TWebMain::HTMLDoRequestDoc(TObject *Sender,
  77.       const WideString URL, const HTMLElement *Element,
  78.       const DocInput *DocInput, WordBool &EnableDefault)
  79. {
  80.   StatusBar->SimpleText = "Connecting to " + URL + "...";
  81. }
  82. //---------------------------------------------------------------------------
  83. void __fastcall TWebMain::HTMLBeginRetrieval(TObject *Sender)
  84. {
  85.   StatusBar->SimpleText = "Connected...";
  86.   URLComboBox->Items->Insert(0, URLComboBox->Text);
  87. }
  88. //---------------------------------------------------------------------------
  89.